<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Model\WishModel;


class WishEnd extends Command
{
	/**
	 * The name and signature of the console command.
	 *
	 * @var string
	 */
	protected $signature = 'wishend';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = '处理失效心愿单';//够30天就清空业绩

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	public function handle()
	{
		//
		Log::info('自动打印,处理失效心愿单');
		//查询正在进行的心愿单
		$wish = WishModel::where('state',1)->select('wish_end_time','id')->get();
		foreach($wish as $k=>$v){
			$now = date('Y-m-d');
			if($now > $v['wish_end_time']){
				WishModel::where('id',$v['id'])->update(['state'=>4]);
			}
		}
	}
}